$(function(){
	var value = $('#verState option:selected') .val();
	if(value == 1){
		$("#oldNotUpdateTr").show();
		$("#oldVerForceTr").show();
	}
	if(value == 0){
		$("#oldNotUpdateTr").hide();
		$("#oldVerForceTr").hide();
	}
});
function showArea(){
	var value = $('#verState option:selected') .val();
	if(value == 1){
		$("#oldNotUpdateTr").show();
		$("#oldVerForceTr").show();
	}
	if(value == 0){
		$("#oldNotUpdateTr").hide();
		$("#oldVerForceTr").hide();
	}
}

//检查员工帐号
function checkAccount(){
	var aa;
	var staffAccount = $('#staffAccount').val();
	var rowId = $('#rowId').val();
	if (CheckUtil.isNotNull(staffAccount)) {
		$.ajax({
			type:"post",
			url:JSSYSMANAGERV1 + "/staff/checkStaffAccount",
			data:{staffAccount:staffAccount, rowId:rowId},
			dataType:"json",
	      	async:false,
	      	success: function(data) {
	      		aa = data;
	      		if (data == 1) {
	      			layer.msg("员工帐号不能重复!");
	      			$('#staffAccount').focus();
    				return;
	      		}
		    }
		})
	}
	return aa;
}
//检查手机号
function checkPhone(){
	var aa;
	var phone = $('#phone').val();
	var rowId = $('#rowId').val();
	if (CheckUtil.isNotNull(phone)) {
		$.ajax({
			type:"post",
			url:JSSYSMANAGERV1 + "/staff/checkStaffPhone",
			data:{phone:phone, rowId:rowId},
			dataType:"json",
	      	async:false,
	      	success: function(data) {
	      		aa = data;
	      		if (data == 1) {
	      			layer.msg("员工手机号码不能重复!");
	      			$('#phone').focus();
    				return;
	      		}
		    }
		})
	}
	return aa;
}


var err = {'1':'添加','2':'修改'};
var action = {'1':'/sysAppVersion/save','2':'/sysAppVersion/update'};
function add(){
	var id = $('#rowId').val();
	var i;
	if (id == '' || id == null) {
		i = 1;//添加
	} else {
		i = 2;//修改
	}
	//var userLogin = $('#staffAccount').val();
	//var userPass = $('#staffPwd').val();
	//var staffName = $('#staffName').val();
	//var qq = $('#qq').val();
	//var mobile = $('#phone').val();
	//var staffType = $('#staffType').val();
	
	var verName = $("#verName").val();
	if (verName == null || verName == '') {
		layer.msg("版本名称不能为空!");
		return;
	}
	var verCode = $("#verCode").val();
	if (verCode == null || verCode == '') {
		layer.msg("版本号不能为空!");
		return;
	}
	var downloadUrl = $("#downloadUrl").val();
	if (downloadUrl == null || downloadUrl == '') {
		layer.msg("下载地址不能为空!");
		return;
	}
	if (i == 1) {//添加的时候对用户密码进行判断
		var channel = $("#channel").val();
		if(channel.length == 0){
			layer.msg("发行渠道不能为空!");
			return;
		}
	}
	$("#saveAndUpdateFrom").attr("action", JSSYSMANAGERV1 + action[i]);
	//var check1 = checkAccount();
	//var check2 = checkPhone();
	//if (check1 == 2 && check2 == 2) {
		if ($("#isReCommit").val() == 0) {
			$("#isReCommit").val(1);
			$("#saveAndUpdateFrom").submit();
		}
	//}
}